import request from '@/utils/request'

// 查询订单列表
export function listOrder(query) {
  return request({
    url: '/shop/order/list',
    method: 'get',
    params: query
  })
}

export function purchaseListOrder(query) {
  return request({
    url: '/shop/order/cgOrderList',
    method: 'get',
    params: query
  })
}

// 查询订单详细
export function getOrder(orderId) {
  return request({
    url: '/shop/order/' + orderId,
    method: 'get'
  })
}

// 删除订单
export function delOrder(orderId) {
  return request({
    url: '/shop/order/' + orderId,
    method: 'delete'
  })
}

// 订单退款
export function refundOrder(orderId) {
  return request({
    url: '/shop/order/refund/' + orderId,
    method: 'post'
  })
}
// 取消退款
export function cancelRefund(orderId) {
  return request({
    url: '/shop/order/cancelRefund/' + orderId,
    method: 'post'
  })
}

// 发货渠道
export function listChannel() {
  return request({
    url: '/shop/order/listChannel',
    method: 'get'
  })
}

// 点击发货
export function clickShip(data) {
  return request({
    url: '/shop/order/ship',
    method: 'post',
    data
  })
}

// 采购基础配置
export function cgBasicConfig(data) {
  return request({
    url: '/shop/order/cgBasicConfig',
    method: 'post',
    data
  })
}

// shop/order/getCgBasicConfig
// 获取采购基础配置
export function getCgBasicConfig() {
  return request({
    url: '/shop/order/getCgBasicConfig',
    method: 'get'
  })
}
// 获取用户列表
export function listUser() {
  return request({
    url: '/shop/order/listUser',
    method: 'get'
  })
}

// 点击发货
export function addCgItem(data) {
  return request({
    url: '/shop/order/addCgItem',
    method: 'post',
    data
  })
}

// 今日推荐收益总金额
export function todayRecommendedIncomeCount() {
  return request({
    url: '/admin/formerOrder/todayRecommendedIncomeCount',
    method: 'get'
  })
}
export function splitOrderReq(data) {
  return request({
    url: '/shop/order/splitOrder',
    method: 'get',
    params: data
  })
}

export function updateSaleStatus(data) {
  return request({
    url: '/shop/order/updateSaleStatus',
    method: 'get',
    params: data
  })
}

export function getTodayData(query) {
  return request({
    url: '/shop/order/getTodaySalesVolume',
    method: 'get',
    params: query
  })
}

export function downloadToday() {
  return request({
    url: '/shop/order/getTodaySalesVolumeExcel',
    method: 'post',
    responseType: 'blob',
  })
}

// 今日推荐收益
export function downloadRecommend() {
  return request({
    url: '/admin/formerOrder/excelTodayRecommendedIncome',
    method: 'get',
    responseType: 'blob',
  })
}

// admin/formerOrder/getAdjustmentFormerOrderExcel
export function downloadAdjustmentFormerOrderExcel() {
  return request({
    url: '/admin/formerOrder/getAdjustmentFormerOrderExcel',
    method: 'post',
    responseType: 'blob',
  })
}

// admin/formerOrder/list   调单列表
export function getFormerOrderList(query) {
  return request({
    url: '/admin/formerOrder/tdList',
    method: 'get',
    params: query
  })
}

// 调单开关
export function adjustmentSwitch(data) {
  return request({
    url: '/admin/formerOrder/adjustmentSwitch',
    method: 'get',
    params: data
  })
}

// 调单完成后下载发货地址
export function exportOrderLogistics() {
  return request({
    url: '/admin/formerOrder/exportOrderLogistics',
    method: 'get',
    responseType: 'blob',
  })
}

// 查询调单状态
export function getAdjustmentSwitch() {
  return request({
    url: '/admin/formerOrder/getAdjustmentSwitch',
    method: 'get'
  })
}

// 采购品移除加入购物车
export function backCartCg(data) {
  return request({
    url: '/admin/formerOrder/backCartCg',
    method: 'post',
    data: data
  })
}

// 采购品指派userid购物车         admin/formerOrder/ assignCartCg
export function assignCartCg(data) {
  return request({
    url: '/admin/formerOrder/assignCartCg',
    method: 'post',
    data: data
  })
}

// 获取开关仓状态
export function getOpenGranary(){
  return request({
    url: '/shop/order/getIsOpenCg',
    method: 'get'
  })
}

// 设置开关仓
export function setOpenGranary(data) {
  return request({
    url: '/shop/order/setCgList',
    method: 'get',
    params: data
  })
}
// 导出订单列表
export function exporCgOrderListtData(){
  return request({
    url: '/shop/order/exporCgOrderListtData',
    method: 'get',
    responseType: 'blob',
  })
}

// 获取采购商品列表
export function ListGoodsOptions() {
  return request({
    url: '/shop/order/splitOrderCgList',
    method: 'get'
  })
}

// 下架采购商品
export function downCgOrder(data) {
  return request({
    url: '/shop/order/downCgOrder',
    method: 'get',
    params:data
  })
}

// 上架采购商品
export function upCgOrder(data) {
  return request({
    url: '/shop/order/downCgOrder',
    method: 'get',
    params:data
  })
}

//获取采购订单历史记录
export function shopOrderLogsList(data) {
  return request({
    url: '/admin/formerOrder/shopOrderLogsList',
    method: 'get',
    params:data
  })
}

// 采购历史订单下载
export function excelShopOrderLogsList(params) {
  return request({
    url: '/admin/formerOrder/excelShopOrderLogsList',
    method: 'get',
    params,
    responseType: 'blob',
  })
}

// 下载未发货订单
export function exporOrderList() {
  return request({
    url: '/shop/order/exporOrderList',
    method: 'get',
    responseType: 'blob',
  })
}